package org.xiaoman.demo.action;

import org.xiaoman.demo.service.IDemoService;
import org.xiaoman.mvcframework.annotation.GPAutowired;
import org.xiaoman.mvcframework.annotation.GPController;
import org.xiaoman.mvcframework.annotation.GPRequestParam;
import org.xiaoman.mvcframework.annotation.GpRequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@GPController
@GpRequestMapping("/demo")
public class DemoAction {
    @GPAutowired
    private IDemoService demoService;

    @GpRequestMapping("/query")
    public void query(HttpServletRequest req, HttpServletResponse resp, @GPRequestParam("name") String name) {
        String result = demoService.get(name);
        try {
            resp.getWriter().write(result);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
